import { BasicFetchResult } from '../model/baseModel';
import { defHttp } from '@/utils/http/axios';
import { downloadBlob } from '@/utils/file/download';
const api = '/amsContractDeposit'
/**
 * 查询租赁合同押金保证金表分页
 * @author Modesto
 * @date 2023-06-02 19:11:59
 */
export const page = (params?: any) =>
  defHttp.get<BasicFetchResult<any>>({ url: api + '/page', params });
/**
 * 查询租赁合同押金保证金表不分页
 * @author Modesto
 * @date 2023-06-02 19:11:59
 */
export const list = (params?: any) =>
  defHttp.get<BasicFetchResult<any>>({ url: api + '/list', params });
/**
 * 添加租赁合同押金保证金表
 * @author Modesto
 * @date 2023-06-02 19:11:59
 */
export const add = (params?: any) => defHttp.post({ url: api + '/add', params });
/**
 * 修改租赁合同押金保证金表
 * @author Modesto
 * @date 2023-06-02 19:11:59
 */
export const edit = (params?: any) => defHttp.post({ url: api + '/edit', params });

/**
 * 删除租赁合同押金保证金表
 * @author Modesto
 * @date 2023-06-02 19:11:59
 */
export const del = (ids: string[]) =>
  defHttp.post({ url: api + '/delete', params: ids });
/**
 * 导出租赁合同押金保证金表
 * @author Modesto
 * @date 2023-06-02 19:11:59
 */
export const exp = (params?: any) => {
  return new Promise<void>((resolve, reject) => {
    defHttp
      .get(
        { responseType: 'blob', url: api + '/export', params },
        { isReturnNativeResponse: true },
      )
      .then((res) => {
        downloadBlob(res);
        resolve();
      })
      .catch(() => {
        reject();
      });
  });
}
